import paramiko

# 设置SFTP连接的参数
hostname = '172.20.228.157'
port = 22  # SSH和SFTP默认端口是22，如果有所更改请相应修改端口号
username = '15575313349'
password = 'TAKA127aimer'

# 创建SSH和SFTP客户端对象
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(hostname, port, username, password)

sftp_client = ssh_client.open_sftp()

# 上传文件
local_file_path = r'C:\Users\17890\Downloads\物料计划 (1).xlsx'
remote_file_path = '/data/demo.xlsx'
sftp_client.put(local_file_path, remote_file_path)

# 关闭SFTP和SSH客户端
sftp_client.close()
ssh_client.close()